package com.inforich.app.api.controller.test;

import cn.hutool.core.thread.ThreadUtil;
import com.alibaba.fastjson2.JSONObject;
import com.inforich.app.api.service.IAppLoginService;
import com.inforich.app.component.LoginUser;
import com.inforich.app.component.LoginUserApp;
import com.inforich.app.component.PreAppRole;
import com.inforich.building.service.IBuildingTypeService;
import com.inforich.common.annotation.RepeatSubmit;
import com.inforich.common.core.domain.AjaxResult;
import com.inforich.common.enums.RoleCodeEnum;
import com.inforich.company.service.ITransportCompanyService;
import java.util.HashMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: some desc
 * @author: HJM
 * @date: 2022/10/24
 */
@RestController
@RequestMapping("/h5api")
public class AppTestController {

  @Autowired
  private IBuildingTypeService buildingTypeService;
  @Autowired
  private ITransportCompanyService transportCompanyService;
  @Autowired
  private IAppLoginService appLoginService;

  @GetMapping("/test")
  public AjaxResult test() {
    ThreadUtil.sleep(1000 * 12);
    return AjaxResult.success("1234");
  }

  @PostMapping("/testPost")
  public AjaxResult testPost(@RequestBody JSONObject param) {
    JSONObject result = new JSONObject();
    param.forEach((key, value) -> {
      String v2 = appLoginService.decrypt(true, String.valueOf(value));
      result.put(key, v2);
    });
    return AjaxResult.success(result);
  }

  @GetMapping("/testUser")
  @PreAppRole("project_admin")
  public String testUser(@LoginUser LoginUserApp loginUserApp) {
    System.out.println("123444");
    return "1234";
  }


}
